<header class="header navbar bg-white shadow">

    <div class="pull-right offscreen-right btn-group tool-button">
        <a class="btn btn-primary navbar-btn" onclick="_selectOn()">确定</a>
    </div>
</header>
<section class="content-wrap bg-white">
    <div class=panel-body style="padding-top: 50px;">
        <div class="table-responsive no-border">
            <table id="datatable_select" class="table table-bordered table-striped mg-t datatable">
                <thead>
                <tr>
                    <th>关键词</th>
            </table>
        </div>
    </div>
</section>
<script language="JavaScript">
    var datatable_select;
    function initdatatable_select() {
        datatable_select = $('#datatable_select').DataTable({
            "dom": '<"toolbar">frtip',
            "searching":false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "ordering": true,
            "language": {
                "url": "${base}/assets/plugins/datatables/cn.json"
            },
            "ajax": {
                "url": "${base}/platform/wx/conf/menu/keywordData",
                "type": "post",
                "data": function (d) {
                    d.wxid ="${wxid}";
                }
            },
            "order": [[0, "desc"]],
            "columns": [
                {"data": "keyword", "bSortable": true}
            ]
        });
        datatable_select.on('click', 'tr', function () {

            if ( $(this).hasClass('selected') ) {
                $(this).removeClass('selected');
            }
            else {
                datatable_select.$('tr.selected').removeClass('selected');
                $(this).addClass('selected');
            }

        });
    }
    function _selectOn() {
        var chks = datatable_select.rows('.selected').data();
        if (chks.length > 0) {
            var ids = [];
            var str='';
            $.each(chks, function (i, n) {
                str+= n.keyword;
            });
            $("#menuKey").val(str);
            $("#dialogKeySelect").modal("hide");
        }else{
            Toast.warning("请先选择内容！");
        }
    }
    $(document).ready(function () {
        initdatatable_select();
    });

</script>
